﻿<Window x:Class="AssignmentsManage.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dc="clr-namespace:AssignmentsManage.DataClasses"
        xmlns:ts="clr-namespace:AssignmentsManage.TemplateSelectors"
        xmlns:ext="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
        xmlns:con="clr-namespace:AssignmentsManage.Converters"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:prop="clr-namespace:AssignmentsManage.Properties"
        xmlns:setc="clr-namespace:SetCLib;assembly=SetCLib"
        xmlns:ctr="clr-namespace:AssignmentsManage.Control"
        xmlns:app="clr-namespace:AssignmentsManage"
        Title="MainWindow"
        xmlns:my="clr-namespace:AssignmentsManage" 
        Closing="Window_Closing"
        Loaded="Window_Loaded"
        xmlns:my1="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:my2="clr-namespace:AssignmentsManage.Windows" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="551" d:DesignWidth="852" SizeToContent="Manual" Icon="/AssignmentsManage;component/Images/1343237094_evolution-tasks.png" Foreground="#FF969696">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles/ComboboxStyles.xaml" />
                <ResourceDictionary Source="Styles/ListViewStyles.xaml" />
                <ResourceDictionary Source="Styles/ButtonStyles.xaml" />
                <ResourceDictionary Source="Styles/Extended/DropDownButtonStyles.xaml" />
                <ResourceDictionary Source="Styles/TextBoxStyles.xaml" />
                <ResourceDictionary Source="Styles/XAMLIcons.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <dc:DataHolder x:Key="DataHolderRes" />
            
            <con:CourseCodeToCoursePropertyConverter x:Key="CourseCodeToCoursePropertyConverter1" Holder="{StaticResource ResourceKey=DataHolderRes}" />
            <con:CourseCodeToCourseObjectConverter x:Key="CourseCodeToCourseObjectConverter1" Holder="{StaticResource ResourceKey=DataHolderRes}" />
            <con:StringToTitleValueConverter x:Key="StringToTitleValueConverter1" />
            <con:AddAmountConverter x:Key="AddAmountConverter1" />
            <con:NumberToPercentStringConverter x:Key="NumberToPercentStringConverter1" />
            <con:CamelCaseToWordsStringConverter x:Key="CamelCaseToWordsStringConverter1" />
            
            <DataTemplate x:Key="CourseSmallDataTemplate" DataType="{x:Type dc:Course}">
                <Grid Height="20">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Margin="2,2,4,2">
                        <Border.Background>
                            <SolidColorBrush Color="{Binding Path=IDColour}" />
                        </Border.Background>
                    </Border>
                    <TextBlock Grid.Column="1" VerticalAlignment="Center">
                        <Run Text="{Binding Path=CourseCode}" /><Run Text=" - " /><Run Text="{Binding Path=Title}" />
                    </TextBlock>
                </Grid>
            </DataTemplate>

            <DataTemplate x:Key="CourseDataTemplate" DataType="{x:Type dc:Course}">
                <Border Margin="2" Background="#01FFFFFF">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="15" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="19" />
                            <RowDefinition Height="19" />
                            <RowDefinition Height="19" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="3" Margin="0,0,5,0">
                            <Border.Background>
                                <SolidColorBrush Color="{Binding Path=IDColour}" />
                            </Border.Background>
                        </Border>
                        <TextBlock Grid.Column="1" Text="{Binding Path=CourseCode}" FontSize="14" />
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Title}" />
                        <TextBlock Grid.Column="1" Grid.Row="2">
                            <Run Text="Total Grade:"  />
                            <Run Text="{Binding Path=TotalGrade, Converter={StaticResource NumberToPercentStringConverter1}}" />
                        </TextBlock>
                    </Grid>
                </Border>
            </DataTemplate>

            <Style x:Key="ListBoxItemContainerStyle" TargetType="{x:Type ListViewItem}">
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListViewItem">
                                <Border Name="Border" Background="#FFEBEBEB" Margin="5" Padding="1">
                                    <Border.RenderTransform>
                                        <ScaleTransform x:Name="scaleTransformer" />
                                    </Border.RenderTransform>
                                    <GridViewRowPresenter />
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="true">
                                        <Setter TargetName="Border" Property="Background" Value="{StaticResource ItemSelectedBackgroundBrush}"/>
                                        <!--<Setter TargetName="Border" Property="Effect">
                                            <Setter.Value>
                                                <DropShadowEffect />
                                            </Setter.Value>
                                        </Setter>-->
                                    </Trigger>
                                    <EventTrigger RoutedEvent="Loaded" SourceName="Border">
                                        <EventTrigger.Actions>
                                            <BeginStoryboard>
                                                <Storyboard Storyboard.TargetName="scaleTransformer" Storyboard.TargetProperty="ScaleY">
                                                    <DoubleAnimation From="0" To="1" Duration="00:00:00.2" />
                                                </Storyboard>
                                            </BeginStoryboard>
                                            <BeginStoryboard>
                                                <Storyboard Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity">
                                                    <DoubleAnimation From="0" To="1" Duration="00:00:00.2" />
                                                </Storyboard>
                                            </BeginStoryboard>
                                        </EventTrigger.Actions>
                                    </EventTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style.Setters>
            </Style>

            <Style x:Key="ListBoxSideItemContainerStyle" TargetType="{x:Type ListBoxItem}">
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Foreground" Value="White" />
                    </Trigger>
                </Style.Triggers>
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Border Name="Border">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter Name="contentArea" />
                                        <Button Grid.Column="1" Width="20" Height="20" Template="{StaticResource ButtonImageTopStyle}" Name="btnCourseItemDelete" Visibility="Collapsed" ToolTip="Delete course" Click="btnCourseItemDelete_Click">
                                            <Image Height="25" Width="25" Source="/AssignmentsManage;component/Images/1342726110_delete.png" Margin="-5,-6,0,0" />
                                        </Button>
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="true">
                                        <Setter TargetName="Border" Property="Background" Value="{StaticResource ItemSelectedBackgroundBrush}" />
                                        <Setter TargetName="btnCourseItemDelete" Property="Visibility" Value="Visible" />
                                        <!--<Setter TargetName="Border" Property="Effect">
                                            <Setter.Value>
                                                <DropShadowEffect />
                                            </Setter.Value>
                                        </Setter>-->
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style.Setters>
            </Style>

            <CollectionViewSource x:Key="collActivities" Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}, Path=DataHolder.ActivityList}">
                <CollectionViewSource.SortDescriptions>
                    <my1:SortDescription PropertyName="DueDate" Direction="Ascending" />
                </CollectionViewSource.SortDescriptions>
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="DateCategory" />
                </CollectionViewSource.GroupDescriptions>
            </CollectionViewSource>

            <DataTemplate DataType="{x:Type setc:TitleValueItem}" x:Key="TitleValueItemSelectionItem">
                <ContentControl Name="presenterArea">
                    <RadioButton IsChecked="{Binding Path=Checked, Mode=TwoWay}" Content="{Binding Path=Title}" GroupName="{Binding Path=Group}" />
                </ContentControl>
            </DataTemplate>

            <DataTemplate DataType="{x:Type setc:TitleValueItem}" x:Key="TitleValueItemHeaderItem">
                <ContentControl Name="presenterArea" Margin="0,4">
                    <TextBlock Text="{Binding Path=Title}" Foreground="Gray" />
                </ContentControl>
            </DataTemplate>

            <ts:TitleValueItemTemplateSelector
                x:Key="TitleValueItemTemplateSelector1"
                TitleValueItemCheckableTemplate="{StaticResource TitleValueItemSelectionItem}"
                TitleValueItemHeaderTemplate="{StaticResource TitleValueItemHeaderItem}" />
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <Border Height="38" DockPanel.Dock="Top" VerticalAlignment="Top" Background="{StaticResource HeaderBackgroundBrush}">
            <DockPanel Background="{StaticResource HeaderBackgroundOverlayBrush}">
                <Button Content="ADD COURSE" Template="{StaticResource ButtonTopStyle}" FontSize="14" Name="btnAddCourse" Click="btnAddCourse_Click" ToolTip="Create a new Course" Foreground="{StaticResource AreaHeaderForegroundBrushMouseOff}" />
                <Button Content="ADD ACTIVITY" Template="{StaticResource ButtonTopStyle}" FontSize="14" Name="btnAddActivity" Click="btnAddActivity_Click" ToolTip="Create a new Activity" Foreground="{StaticResource AreaHeaderForegroundBrushMouseOff}" />
                <Button HorizontalAlignment="Right" Width="40" Template="{StaticResource ButtonImageTopStyle}" Name="btnAbout" DockPanel.Dock="Right" ToolTip="About" Click="btnAbout_Click">
                    <Border Margin="7" Background="{StaticResource CODE.Framework.CanvasIconHelp}" />
                </Button>
                <Button HorizontalAlignment="Right" Width="40" Template="{StaticResource ButtonImageTopStyle}" Name="btnSetup" Click="btnSetup_Click" DockPanel.Dock="Right" ToolTip="Setup">
                    <Border Margin="7" Background="{StaticResource CODE.Framework.Canvas.IconSettings}" />
                </Button>
                <Button HorizontalAlignment="Right" Width="40" Template="{StaticResource ButtonImageTopStyle}" Name="btnSave" DockPanel.Dock="Right" Click="btnSave_Click" ToolTip="Save All Changes">
                    <Border Margin="7" Background="{StaticResource CODE.Framework.Canvas.IconSave}"></Border>
                </Button>
            </DockPanel>
        </Border>

        <Border Height="20" DockPanel.Dock="Bottom" VerticalAlignment="Bottom">
            <StatusBar Background="{x:Null}">
                <TextBlock>
                    <Run Text="Displaying " />
                    <Run Text="{Binding Path=ItemsSource.Count, Mode=OneWay, ElementName=lstActivities}" />
                    <Run Text=" of "  />
                    <Run Text="{Binding Path=DataHolder.TotalActivityCount, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}}" Name="runTotalActivities" />
                    <Run Text=" activities"  />
                </TextBlock>
                <Separator />
                <TextBlock Name="txtbLastSave">
                    <Run Text="Last Save: " /><Run Text="{Binding Path=DataHolder.LastSave, RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Name="runLastSave" />
                </TextBlock>
            </StatusBar>
        </Border>

        <Border DockPanel.Dock="Left" HorizontalAlignment="Left" Width="150" BorderThickness="1" BorderBrush="{StaticResource AreaBorderBrush}" Margin="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Label Content="Courses" FontSize="14" Foreground="{StaticResource AreaHeaderForegroundBrush}" Background="{StaticResource AreaHeaderBrush}" />
                <ListBox Grid.Row="1" BorderThickness="0" ItemTemplate="{StaticResource CourseDataTemplate}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}, Path=DataHolder.CourseList}" Name="lstCourses" SelectionChanged="lstCourses_SelectionChanged" ItemContainerStyle="{StaticResource ListBoxSideItemContainerStyle}" MouseDoubleClick="lstCourses_MouseDoubleClick">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Margin="2,4" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>
            </Grid>
        </Border>

        <Border HorizontalAlignment="Stretch" BorderThickness="1" BorderBrush="{StaticResource AreaBorderBrush}" Margin="1" Padding="0">
            <Grid Background="{StaticResource AreaHeaderBrush}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="23" />
                    <RowDefinition Height="425*" />
                </Grid.RowDefinitions>

                <ext:DropDownButton Content="Test" FontSize="14" Foreground="{StaticResource AreaHeaderForegroundBrush}" Background="{StaticResource AreaHeaderBrush}" Name="ddbtnFilter" HorizontalContentAlignment="Left" Style="{StaticResource DropDownButtonStyleCustom}" ToolTip="Click to change filters for displayed activities">
                    <ext:DropDownButton.Resources>
                        <setc:TitleValueItemCollection x:Key="filter_source" ItemCheckedChanged="TitleValueItemCollection_ItemCheckedChanged">
                            <setc:TitleValueItem Title="Filter In:" IsHeader="True" />
                            <setc:TitleValueItem Title="All Activities" UID="_All" Group="FilterIn" Checked="True" />
                            <setc:TitleValueItem Title="Selected Course Activities" UID="_SelectedCourse" Group="FilterIn" />

                            <setc:TitleValueItem Title="Activity Type:" IsHeader="True" />
                            <setc:TitleValueItem Title="All" UID="__ActivityAll" Group="ActivityType" Checked="True" />
                            <setc:TitleValueItem Title="Midterms" UID="__Midterms" Group="ActivityType" />
                            <setc:TitleValueItem Title="Tests" UID="__Tests" Group="ActivityType" />
                            <setc:TitleValueItem Title="Labs" UID="__Labs" Group="ActivityType" />
                            <setc:TitleValueItem Title="Quizzes" UID="__Quizzes" Group="ActivityType" />
                            <setc:TitleValueItem Title="Assignments" UID="__Assignments" Group="ActivityType" />
                            <setc:TitleValueItem Title="Final Exams" UID="__FinalExams" Group="ActivityType" />
                            <setc:TitleValueItem Title="Reading Assignments" UID="__ReadingAssignments" Group="ActivityType" />

                            <setc:TitleValueItem Title="Status:" IsHeader="True" />
                            <setc:TitleValueItem Title="All" UID="__StatusAll" Group="Status" Checked="True" />
                            <setc:TitleValueItem Title="Not Started" UID="__NotStarted" Group="Status" />
                            <setc:TitleValueItem Title="In Progress" UID="__InProgress" Group="Status" />
                            <setc:TitleValueItem Title="Studying" UID="__Studying" Group="Status" />
                            <setc:TitleValueItem Title="Finished" UID="__Finished" Group="Status" />
                            <setc:TitleValueItem Title="Graded" UID="__Graded" Group="Status" />
                        </setc:TitleValueItemCollection>
                    </ext:DropDownButton.Resources>
                    <ext:DropDownButton.DropDownContent>
                        <StackPanel Margin="5,5,0,5">
                            <ItemsControl ItemsSource="{StaticResource filter_source}" ItemTemplateSelector="{StaticResource TitleValueItemTemplateSelector1}" Margin="0,0,0,10">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ext:DropDownButton, AncestorLevel=1}, Path=ActualWidth, ConverterParameter=-9, Converter={StaticResource AddAmountConverter1}}" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                            <TextBlock>
                                <Hyperlink Name="hypResetFilters" Click="hypResetFilters_Click">Reset Filters</Hyperlink>
                            </TextBlock>
                        </StackPanel>
                    </ext:DropDownButton.DropDownContent>
                </ext:DropDownButton>

                <ListView Grid.Row="1"
                          BorderThickness="0"
                          ItemsSource="{Binding Source={StaticResource collActivities}}"
                          Name="lstActivities"
                          SelectionChanged="lstActivities_SelectionChanged"
                          ItemContainerStyle="{StaticResource ListBoxItemContainerStyle}"
                          SelectionMode="Extended"
                          Margin="0,2,0,0" Drop="lstActivities_Drop"
                          AllowDrop="True"
                          DragOver="lstActivities_DragOver">
                    <ListView.ContextMenu>
                        <ContextMenu ItemsSource="{Binding Source={x:Static prop:Settings.Default}, Path=columnVisiblity, Mode=TwoWay}" Unloaded="ContextMenu_Unloaded">
                            <ContextMenu.ItemTemplate>
                                <DataTemplate DataType="{x:Type setc:TitleValue}">
                                    <MenuItem Header="{Binding Path=Title}" IsCheckable="True" IsChecked="{Binding Path=Visible, Mode=TwoWay}" />
                                </DataTemplate>
                            </ContextMenu.ItemTemplate>
                        </ContextMenu>
                    </ListView.ContextMenu>
                    <ListView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Margin" Value="0,0,0,5"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                                <Expander BorderBrush="#FFA4B97F" 
                          BorderThickness="0,0,0,1" Margin="0,5,0,0" Name="expanderCategory" Collapsed="expanderCategory_Collapsed" Expanded="expanderCategory_Expanded" Loaded="expanderCategory_Loaded">
                                                    <Expander.Header>
                                                        <DockPanel>
                                                            <TextBlock Text="{Binding Path=Name}" 
                                 Margin="5,0,0,5" FontSize="15" FontFamily="Arial" Foreground="{StaticResource TitleTextForegroundBrush}" />
                                                            <TextBlock
                                                                Margin="5,0,0,5" FontSize="15" FontFamily="Arial" Foreground="{StaticResource TitleTextForegroundBrush}">
                                                                <Run Text="(" /><Run Text="{Binding Path=ItemCount, Mode=OneWay}"  /><Run Text=")" />
                                                            </TextBlock>
                                                        </DockPanel>
                                                    </Expander.Header>
                                                    <Expander.Content>
                                                        <ItemsPresenter />
                                                    </Expander.Content>
                                                </Expander>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </GroupStyle.ContainerStyle>
                        </GroupStyle>
                    </ListView.GroupStyle>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="Course" Width="45">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <Border Name="borderCourse" Margin="13,4" Width="10" Height="28">
                                                <Border.Background>
                                                    <SolidColorBrush Color="{Binding Path=CourseInCode, Converter={StaticResource CourseCodeToCoursePropertyConverter1}, ConverterParameter=IDColour}" />
                                                </Border.Background>
                                            </Border>
                                            <ComboBox Height="21" Name="cboCourse" Visibility="Collapsed" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}, Path=DataHolder.CourseList}" ItemTemplate="{StaticResource CourseSmallDataTemplate}" SelectedItem="{Binding Path=CourseInCode, Converter={StaticResource CourseCodeToCourseObjectConverter1}}" Width="35" Style="{StaticResource GenComboBoxStyle}" />
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="borderCourse" Property="Visibility" Value="Hidden" />
                                                <Setter TargetName="cboCourse" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Flag">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <ToggleButton IsChecked="{Binding Path=Flagged, Mode=TwoWay}">
                                            <ToggleButton.Style>
                                                <Style TargetType="{x:Type ToggleButton}">
                                                    <Style.Setters>
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                                    <Border Background="#01000000" Width="21" Height="21">
                                                                        <Image Name="imgFlag" Source="/AssignmentsManage;component/Images/flag_mark_gray.png" ToolTip="Important Flag" />
                                                                    </Border>
                                                                    <ControlTemplate.Triggers>
                                                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Flagged}" Value="True">
                                                                            <DataTrigger.Setters>
                                                                                <Setter TargetName="imgFlag" Property="Source" Value="/AssignmentsManage;component/Images/flag_mark_red.png" />
                                                                            </DataTrigger.Setters>
                                                                        </DataTrigger>
                                                                    </ControlTemplate.Triggers>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style.Setters>
                                                </Style>
                                            </ToggleButton.Style>
                                        </ToggleButton>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Title">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <TextBlock Name="txtTitle" Text="{Binding Path=Title}" Visibility="Visible" MinWidth="90" />
                                            <ctr:LimitedTextBox x:Name="txtbTitle" Text="{Binding Path=Title, Mode=TwoWay}" Visibility="Collapsed" MinWidth="90" Style="{StaticResource GeneralTextBox}" />
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtTitle" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="txtbTitle" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Status">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <TextBlock Name="txtStatus" Text="{Binding Path=ActivityStatusType, Converter={StaticResource CamelCaseToWordsStringConverter1}}" Visibility="Visible" MinWidth="90" />
                                            <ComboBox Name="txtbStatus" SelectedIndex="{Binding Path=ActivityStatusType_Index, Mode=TwoWay}" Visibility="Collapsed" MinWidth="90" Style="{StaticResource GenComboBoxStyle}">
                                                <sys:String>Not Started</sys:String>
                                                <sys:String>In Progress</sys:String>
                                                <sys:String>Studying</sys:String>
                                                <sys:String>Finished</sys:String>
                                                <sys:String>Graded</sys:String>
                                            </ComboBox>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtStatus" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="txtbStatus" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Type">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <TextBlock Name="txtType" Text="{Binding Path=ActivityType, Converter={StaticResource CamelCaseToWordsStringConverter1}}" Visibility="Visible" MinWidth="135" />
                                            <ComboBox Name="txtbType" SelectedIndex="{Binding Path=ActivityType_Index, Mode=TwoWay}" Visibility="Collapsed" MinWidth="135" ItemsSource="{Binding Path=ActivityType_Index}" Style="{StaticResource GenComboBoxStyle}">
                                                <sys:String>Assignment</sys:String>
                                                <sys:String>Test</sys:String>
                                                <sys:String>Quiz</sys:String>
                                                <sys:String>Lab</sys:String>
                                                <sys:String>Final Exam</sys:String>
                                                <sys:String>Midterm</sys:String>
                                                <sys:String>Reading Assignment</sys:String>
                                            </ComboBox>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtType" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="txtbType" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Due Date">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <TextBlock Name="txtDueDate" Text="{Binding Path=DueDate, StringFormat=\{0:f\}}" Visibility="Visible" MinWidth="160" />
                                            <ext:DateTimePicker Name="dtpDueDate" Visibility="Collapsed" Value="{Binding Path=DueDate, Mode=TwoWay}" />
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtDueDate" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="dtpDueDate" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Grade">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type dc:Activity}">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <TextBlock Name="txtGrade" Grid.ColumnSpan="3" Visibility="Hidden" MinWidth="120">
                                                <Run Text="{Binding Path=Grade.Numerator}" />
                                                <Run Text="/"  />
                                                <Run Text="{Binding Path=Grade.Denominator}" />
                                                <Run Text=" ("  /><Run Text="{Binding Path=Grade.Percentage, Converter={StaticResource NumberToPercentStringConverter1}, Mode=OneWay}" /><Run Text=")" />
                                            </TextBlock>
                                            <TextBox Name="txtbGrade" Text="{Binding Path=Grade.Numerator, Mode=TwoWay}" Visibility="Collapsed" MinWidth="50" Style="{StaticResource GeneralTextBox}" ToolTip="Grade" />
                                            <TextBlock Name="txtOutOf" Grid.Column="1" Text="/" Padding="3,0" Visibility="Collapsed" />
                                            <TextBox Name="txtbGradeEnd" Grid.Column="2" MinWidth="50" Visibility="Collapsed" Text="{Binding Path=Grade.Denominator, Mode=TwoWay}" Style="{StaticResource GeneralTextBox}" ToolTip="Total Possible Marks" />
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="True" />
                                                    <Condition Binding="{Binding Path=EditingStatus_Multiple}" Value="False" />
                                                    <Condition Binding="{Binding Path=ActivityStatusType}" Value="Graded" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtGrade" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="txtbGrade" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="txtOutOf" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="txtbGradeEnd" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding Path=EditingStatus_Extra}" Value="False" />
                                                    <Condition Binding="{Binding Path=ActivityStatusType}" Value="Graded" />
                                                </MultiDataTrigger.Conditions>
                                                <Setter TargetName="txtGrade" Property="Visibility" Value="Visible" />
                                            </MultiDataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Options">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Button Margin="3,0" Width="20" Name="btnActivityOK" Click="btnActivityOK_Click" Visibility="Hidden" IsDefault="True" ToolTip="OK (Enter)" Template="{StaticResource ButtonImageTopStyle}">
                                                <Image Source="/AssignmentsManage;component/Images/1342726072_check.png" Height="25" Width="25" />
                                            </Button>
                                            <Button Margin="3,0" Width="20" Name="btnActivityDelete" Click="btnActivityDelete_Click" Visibility="Hidden" ToolTip="Delete" Template="{StaticResource ButtonImageTopStyle}">
                                                <Image Source="/AssignmentsManage;component/Images/1342726110_delete.png" Height="25" Width="25" />
                                            </Button>
                                            <Button Margin="5,0" Width="20" Name="btnActivityComments" Visibility="Hidden" Template="{StaticResource ButtonImageTopStyle}" Click="btnActivityComments_Click">
                                                <Button.ToolTip>
                                                    <TextBlock>
                                                        <Run Text="Comments"  />
                                                        <LineBreak />
                                                        <Run FontStyle="Italic" Text="{Binding Path=CommentsPreview, Mode=OneWay}" />
                                                    </TextBlock>
                                                </Button.ToolTip>
                                                <Image Source="/AssignmentsManage;component/Images/1342726165_comment.png" Height="20" Width="20" />
                                            </Button>
                                            <Button Margin="3,0" Width="20" Name="btnActivityLinkedFiles" Visibility="Hidden" Template="{StaticResource ButtonImageTopStyle}" Click="btnActivityLinkedFiles_Click">
                                                <Button.ToolTip>
                                                    <ToolTip>
                                                        <TextBlock>
                                                            <Run Text="Linked Files (" /><Run Text="{Binding Path=LinkedFiles.Count, Mode=OneWay}" /><Run Text=")"  />
                                                        </TextBlock>
                                                    </ToolTip>
                                                </Button.ToolTip>
                                                <Image Source="/AssignmentsManage;component/Images/Black_Paperclip.png" Height="25" Width="20" />
                                            </Button>
                                        </StackPanel>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding Path=EditingStatus_Extra}" Value="True">
                                                <Setter TargetName="btnActivityOK" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="btnActivityDelete" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="btnActivityComments" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="btnActivityLinkedFiles" Property="Visibility" Value="Visible" />
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Grid>
        </Border>
        
        
    </DockPanel>
</Window>
